<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Document</title>
	<style>
		.parent{
			width: 200px;
			height: 200px;
			background-color: red;
			/* 1.1设置父容器为弹性盒 */
			/* display: flex; */
			/* 2.1设置父容器为伸缩盒/宫格布局*/
			display: flex;/* display:grid*/
			/* 2.2 设置弹性元素在交叉轴和主轴排列方式为center */
			/* 设置弹性元素在主轴方向为居中 --水平居中 */
			justify-content: center;
			/* 设置弹性元素在交叉轴方向为居中 --垂直居中 */
			align-items: center;

		}
		.child{
			width: 100px;
			height: 100px;
			background-color: blue;
			/* 1.2设置margin:auto */
			/* margin: auto; */
		}
	</style>
</head>
<body>
	<div class="parent">
		<div class="child"></div>
	</div>
</body>
</html>